package avicit.rme.back.apigenerator.dto;


import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class ApiDataQueryConfig {
    private String apiPath;
    private String tableName;
    private List<String> fields;
    private List<String> conditions;
    private String orderBy;
    private int pageSize;

    // Getters and Setters
    public String getApiPath() { return apiPath; }
    public void setApiPath(String apiPath) { this.apiPath = apiPath; }
    public String getTableName() { return tableName; }
    public void setTableName(String tableName) { this.tableName = tableName; }
    public List<String> getFields() { return fields; }
    public void setFields(List<String> fields) { this.fields = fields; }
    public List<String> getConditions() { return conditions; }
    public void setConditions(List<String> conditions) { this.conditions = conditions; }
    public String getOrderBy() { return orderBy; }
    public void setOrderBy(String orderBy) { this.orderBy = orderBy; }
    public int getPageSize() { return pageSize; }
    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    public List<String> getRequestParams() {
        // 实现从conditions中提取参数名的逻辑
        // 示例实现，根据实际需求调整
        return conditions != null ?
                conditions.stream()
                        .filter(c -> c.contains("=?"))
                        .map(c -> c.split("=")[0].trim())
                        .collect(Collectors.toList()) :
                Collections.emptyList();
    }
}